package com.ruoyi.finance.service.impl;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.finance.domain.CommissionOverdue;
import com.ruoyi.finance.service.ICommissionOverdueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.exception.base.BaseException;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.finance.mapper.CommissionOverdueMapper;

import java.util.List;

/**
 * 每月逾期Service业务层处理
 *
 * @author admin
 * @date 2023-10-17
 */
@Service
public class CommissionOverdueServiceImpl implements ICommissionOverdueService {
    @Autowired
    private CommissionOverdueMapper commissionOverdueMapper;

    /**
     * 查询每月逾期
     *
     * @param id 每月逾期ID
     * @return 每月逾期
     */
    @Override
    public CommissionOverdue selectCommissionOverdueById(Long id) {
        return commissionOverdueMapper.selectCommissionOverdueById(id);
    }

    /**
     * 查询每月逾期列表
     *
     * @param commissionOverdue 每月逾期
     * @return 每月逾期
     */
    @Override
    public List<CommissionOverdue> selectCommissionOverdueList(CommissionOverdue commissionOverdue) {
        return commissionOverdueMapper.selectCommissionOverdueList(commissionOverdue);
    }

    /**
     * 新增每月逾期
     *
     * @param commissionOverdue 每月逾期
     * @return 结果
     */
    @Override
    public int insertCommissionOverdue(CommissionOverdue commissionOverdue) {
        return commissionOverdueMapper.insertCommissionOverdue(commissionOverdue);
    }

    /**
     * 修改每月逾期
     *
     * @param commissionOverdue 每月逾期
     * @return 结果
     */
    @Override
    public int updateCommissionOverdue(CommissionOverdue commissionOverdue) {
        return commissionOverdueMapper.updateCommissionOverdue(commissionOverdue);
    }

    /**
     * 批量删除每月逾期
     *
     * @param ids 需要删除的每月逾期ID
     * @return 结果
     */
    @Override
    public int deleteCommissionOverdueByIds(Long[] ids) {
        return commissionOverdueMapper.deleteCommissionOverdueByIds(ids);
    }

    /**
     * 删除每月逾期信息
     *
     * @param id 每月逾期ID
     * @return 结果
     */
    @Override
    public int deleteCommissionOverdueById(Long id) {
        return commissionOverdueMapper.deleteCommissionOverdueById(id);
    }

    @Override
    public AjaxResult importCommissionOverdue(MultipartFile file) {
        try {
            //ExcelUtil<CommissionOverdue> util = new ExcelUtil<>(CommissionOverdue.class);
            //List<CommissionOverdue> list = null;
            //list = util.importExcel(file.getInputStream());
            //if (StringUtils.isNull(list) || list.size() == 0) {
            //    throw new BaseException("导入数据不能为空！");
            //} else {
            //    commissionOverdueMapper.batchUpdateCommissionOverdue(list);
            //}
        } catch (Exception e) {
            e.printStackTrace();
        }
        return AjaxResult.success();
    }

    //private void saveCommissionOverdue() {
    //    commissionOverdueMapper.getOneByPiNoAndDate();
    //}
}
